package com.xy.yunduo.web.filter;

import org.springframework.web.servlet.i18n.SessionLocaleResolver;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Locale;

//@Component
//@WebFilter(filterName = "messageLocaleFilter",urlPatterns = "/*")
//@Order(2)
public class MessageLocaleFilter  extends BaseFilter{
    @Override
    protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
            throws IOException, ServletException {
        Locale locale = new Locale("zh", "CN");
        request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME,locale);
        chain.doFilter(request, response);
    }
}
